package com.base.vistter.iframe.inverter.controller;

import com.base.vistter.iframe.bean.Result;
import com.base.vistter.iframe.entity.InverterDevicesPowerSummary;
import com.base.vistter.iframe.exception.IframeException;
import com.base.vistter.iframe.model.DevicesSummaryPowerRequest;
import com.base.vistter.iframe.service.InverterDevicesPowerSummaryService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/devices/power/summary")
public class InverterDevicesPowerSummaryController {
    @Resource(name = "inverterDevicesPowerSummaryService")
    private InverterDevicesPowerSummaryService inverterDevicesPowerSummaryService;
    @PostMapping(value = "/statistics", produces = "application/json;charset=utf-8")
    public Result<List<InverterDevicesPowerSummary>> statistics(@RequestBody DevicesSummaryPowerRequest devicesSummaryPowerRequest) throws IframeException {
        return Result.ok(inverterDevicesPowerSummaryService.statisticsDevices(devicesSummaryPowerRequest));
    }

}
